from tests import BlogLogin
from tests import BlogList
from tests import BlogDetail
from tests import BlogEdit
from common.Utils import BlogDriver

if __name__ == "__main__":
    print("=" * 50)
    print("开始执行博客系统自动化测试")
    print("=" * 50)

    # 创建登录测试实例
    login_test = BlogLogin.BlogLogin()

    print("\n执行登录失败测试...")
    if login_test.LoginFailTest():
        print("✅ 登录失败测试通过")
    else:
        print("❌ 登录失败测试失败")

    print("\n执行登录成功测试...")
    if login_test.LoginSucTest():
        print("✅ 登录成功测试通过")
    else:
        print("❌ 登录成功测试失败")
        # 如果登录失败，退出测试
        BlogDriver.driver.quit()
        exit(1)

    print("\n执行博客列表测试...")
    list_test = BlogList.BlogList()
    if list_test.ListTestByLogin():
        print("✅ 博客列表测试通过")

    print("\n执行博客详情测试...")
    detail_test = BlogDetail.BlogDetail()
    if detail_test.DetailTestByLogin():
        print("✅ 博客详情测试通过")

    print("\n执行博客编辑测试...")
    edit_test = BlogEdit.BlogEdit()
    if edit_test.EditSucTestByLogin():
        print("✅ 博客编辑测试通过")

    print("\n" + "=" * 50)
    print("所有测试执行完成!")
    print("=" * 50)

    # 退出浏览器
    BlogDriver.driver.quit()